home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / plnk081.zip / pilot-link.0.8.1 / Java / Pdapilot / appointment / time.java < prev   
Encoding:
Java Source  |  1997-08-08  |  892 b   |  51 lines

  1.  
  2. package Pdapilot.appointment;
  3.  
  4. public class time {
  5.     private int idx;
  6.     
  7.     final static private String[] names = 
  8.         { "Minutes", "Hours", "Days" };
  9.  
  10.     public static time Minutes = new time(0);
  11.     public static time Hours =  new time(1);
  12.     public static time Days = new time(2);
  13.     
  14.     private static time[] objs;
  15.     
  16.     private time(int value) {
  17.         this.idx = value;
  18.     }
  19.     
  20.     public static time get(int value) {
  21.         return objs[value];
  22.     }
  23.     public static time get(String value) {
  24.         int i;
  25.         for(i=0;i<names.length;i++)
  26.             if (names[i].equals(value))
  27.                 return objs[i];
  28.         return null;
  29.     }
  30.     public static String[] getNames() {
  31.         return names;
  32.     }
  33.     
  34.     public String toString() {
  35.         return "time."+names[idx];
  36.     }
  37.         
  38.     public int getValue() {
  39.         return idx;
  40.     }
  41.     public String getName() {
  42.         return names[idx];
  43.     }
  44.  
  45.     static {
  46.         objs = new time[3];
  47.         objs[0] = time.Minutes;
  48.         objs[1] = time.Hours;
  49.         objs[2] = time.Days;
  50.     }
  51. };